<template>
  <div class="app-container">

  </div>
</template>

<script>
import {getSsoToken} from "@/api/sso";
import {setToken} from "@/utils/auth";

export default {
  name: 'sso',
  data() {
    return {
    }
  },
  created() {
    const ticket = this.$route.query.ticket
    if (ticket){
      getSsoToken(ticket).then(res => {
        setToken(res.data.token)
        this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
      }).catch(() => {
        this.$router.push("/noAuth")
      })
    } else {
      window.open("https://cas.nwnu.edu.cn/login?service=https://jwda.nwnu.edu.cn/sso", "_self")
    }
  },
  methods: {}
}
</script>
